package adventuregame;

import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * Reads a config file from file root.
 * @author Jesper & Simon
 */
public class Config {

	Properties configFile = new Properties();
	Person gamer = null;

	/**
	 * Get file test.properties
	 */
	public Config() {
		String filename = "test.properties";
		getFile(filename);
	}

	/**
	 * Get filename from string parameter
	 * @param filename String, name of filename to get
	 */
	public Config(String filename) {
		getFile(filename);
	}

	/**
	 * Get filename from string parameter
	 * @param filename String, name of filename to get
	 */
	private void getFile(String filename) {
		try {
			configFile.load(new FileReader(filename));
		} catch (IOException ex) {
			Logger.getLogger(Config.class.getName()).log(Level.SEVERE, null, ex);
		}
	}

	/**
	 * Get property string
	 * @param property String which property to get from file
	 * @return property value in a String
	 */
	public String getProperty(String property) {
		return configFile.getProperty(property);
	}
}
